package jz.dataCenter;

import sessionFilterClient.dataCenter.ApDataCenter;
import sessionFilterClient.dataCenter.IDataCenterPushThread;
import SoftFan.dataCenter.DataCenterDataLogPush;
import SoftFan.dataCenter.FileSendThread;

public class JzDataCenterClientPushThread implements IDataCenterPushThread {

	private ApDataCenter			apDataCenter;

	private DataCenterDataLogPush	pushThread			= null;

	private FileSendThread			fileSendThread		= null;

	
	public JzDataCenterClientPushThread(ApDataCenter apDataCenter) {
		super();
		this.apDataCenter = apDataCenter;
	}

	public ApDataCenter getApDataCenter() {
		return apDataCenter;
	}

	public void setApDataCenter(ApDataCenter apDataCenter) {
		this.apDataCenter = apDataCenter;
	}

	public void startup() {
		if (pushThread == null) {
			pushThread = new DataCenterDataLogPush(this.apDataCenter);
			pushThread.start();
		}
		if (fileSendThread == null) {
			fileSendThread = new FileSendThread(this.apDataCenter, "STORE");
			fileSendThread.start();
		}
	}

	public void shutdown() {
		if (pushThread != null) {
			pushThread.doDone();
			pushThread = null;
		}
		if (fileSendThread != null) {
			fileSendThread.doDone();
			fileSendThread = null;
		}
	}
}
